﻿using System.Configuration;

namespace WarmUpService
{
	public class TargetDetails : ConfigurationSection
	{
		public TargetDetails()
		{
		}

		[ConfigurationProperty("details")]
		public TargetDetailCollection details
		{
			get
			{
				return (TargetDetailCollection)(this["details"]);
			}
		}
	}

	public class TargetDetailCollection : ConfigurationElementCollection
	{
		public TargetDetailCollection()
		{
		}

		protected override ConfigurationElement CreateNewElement()
		{
			return new TargetDetailElement();
		}

		protected ConfigurationElement CreateNewElement(
			string urlName, string interval)
		{
			return new TargetDetailElement(urlName, interval);
		}

		public new int Count
		{
			get
			{
				return base.Count;
			}
		}

		public TargetDetailElement this[int index]
		{
			get
			{
				return (TargetDetailElement)BaseGet(index);
			}
			set
			{
				if (BaseGet(index) != null)
				{
					BaseRemoveAt(index);
				}
				BaseAdd(index, value);
			}
		}

		protected override object GetElementKey(ConfigurationElement element)
		{
			return ((TargetDetailElement)element).urlName;
		}
	}

	public class TargetDetailElement : ConfigurationElement
	{
		public TargetDetailElement(string url, string timeInterval)
		{
			urlName = url;
			timeSpan = timeInterval;
		}

		public TargetDetailElement()
		{
		}

		[ConfigurationProperty("urlName")]
		public string urlName
		{
			get
			{
				return this["urlName"].ToString();
			}
			set
			{
				this["urlName"] = value;
			}
		}

		[ConfigurationProperty("timeSpan")]
		public string timeSpan
		{
			get
			{
				return (this["timeSpan"]).ToString();
			}
			set
			{
				this["timeSpan"] = value;
			}
		}
	}
}
